<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no" />
    <title>定制名片</title>
    @include('index.css')
</head>
<body>
<div id="wrap" class="flexv">
    <div id="header" class="flex centerv header">
        <a href="index.html" class="flex logo" style="background:url({{asset('image/index/logo.png')}});background-size:cover;"></a>
        <div class="flexitem center title"><neq name="pinpai" value="">{{$brandName}}<else />名片</neq>定制</div>
        <a href="/" class="flexv center brand">
            <span class="flex">品牌</span>
            <i class="flex bc bc-down"></i>
        </a>
    </div>
    <div id="main" class="flexitemv">
        @if($lists != null)
            <div id="cardlist" style="padding-bottom:50px;">
                @foreach($lists as $list)
                    <div class="lists">
                        <div class="flex cardpic">
                            @foreach($list->template as $l)
                            <div class="flex pics"><span><img src="{{asset('css/upload')}}{{$l->effect_src}}" /></span></div>
                            @endforeach
                        </div>
                        <h2 class="flex"><span class="flexitemv">{{$list->card_name}}</span><em>&yen;{{$list->price}}/500张</em></h2>
                        <a href="/indent?id={{$list->id}}" class="flex center buyit">立即定制</a>
                    </div>
                @endforeach
            </div>
            @else
            <div id="empty" class="flexitemv center">
                <i class="flex bc bc-empty icon"></i>
                <p>该品牌下尚无名片模板~</p>
            </div>
        @endif
    </div>
</div>
<script src="http://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script>
<script src="{{asset('js/index/functions.js')}}"></script>
<script type="text/javascript">
    /**
     * get参数转 post参数
     * @param paramstr [附加参数]
     * @param url [get链接]
     */
    function searchToJson(paramstr,url){
        if(paramstr == '') return {};
        var url = url || window.location.search;
        var newurl = url.substr(url.indexOf('?') + 1);
        var urlstr = (newurl == '') ? paramstr : newurl + '&' + paramstr;
        var arr = urlstr.split('&'),newarr = [];
        for(var i = 0; i < arr.length; i++){
            var strarr = arr[i].split('=');
            var arrstr = '"' + strarr[0] + '":"' + (strarr[1] || '') + '"';
            newarr.push(arrstr);
        }
        return JSON.parse('{' + newarr.join(',') + '}');
    }
    var url = window.location.href,loadBtn = false,page = 1,canload = true;
    var ih = $('#main').height(),lh = $('#cardlist').height();
    if(lh < ih) $('#cardlist').removeAttr('style');
    $('#main').on('scroll',function (){
        if(!canload || lh < ih) return;
        var h = $(this).scrollTop();
        if((ih + h) >= lh - 1){
            if(loadBtn) return;
            loadBtn = true;
            page++;
            $('<div id="more" class="flex center"><i></i><span>正在加载..</span></div>').appendTo($('#cardlist'));
//            var post = searchToJson('page=' + page);
            $.get(url+'&page='+page,function (ret){
                console.log(ret);
                if(ret.state == 1){
                    $('#cardlist').append(ret.html);
                    $('#more').remove();
                    lh = $('#cardlist').height();
                }else{
                    canload = false;
                    $('#more').html('<span>' + ret.html + '</span>');
                }
                loadBtn = false;
            },'json');
        }
    });

    /**
     *  年底快递停止发货通知
     */
    //showAlert('春节公告','活动结束后即将恢复原价，请抓紧订购，活动截至时间2017年2月5号晚上24点，逾期将恢复原价45元。',[{t:'知道了'}]);
    @if($tips != '')
        showAlert('公告','{{$tips->content}}',[{t:'知道了'}]);
    @endif
</script>
</body>
</html>